package com.boboPlanet.controller;

import com.boboPlanet.comm.result.ResponseResult;
import com.boboPlanet.entity.vo.DictConfigVO;
import com.boboPlanet.entity.vo.InvalidConfigVO;
import com.boboPlanet.service.DictConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: TODO 字典配置
 * @Author: mis_wu
 * @Date: 2022/9/19
 **/
@RestController
@RequestMapping("/sysMainDictConfig")
@Api(tags = "系统字典配置")
@Slf4j
public class DictConfigController {

    @Autowired
    private DictConfigService dictConfigService;

    @GetMapping("/findDictConfigByPage")
    @ApiOperation("分页获取字段配置")
    public ResponseResult<DictConfigVO> findDictConfigByPage(Integer page, Integer size, String configName){
        log.info("获取字段配置参数:{} == {} == {}",page,size,configName);
        return dictConfigService.findDictConfigByPage(page,size,configName);
    }

    @GetMapping("/getInvalidFlagData")
    @ApiOperation("获取字段配置")
    public ResponseResult<List<InvalidConfigVO>> getInvalidFlagData(String configName){
        return dictConfigService.getInvalidFlagData(configName);
    }

    @GetMapping("/openInvalidConfig/{id}")
    @ApiOperation("开启作废配置")
    public ResponseResult<Boolean> openInvalidConfig(@PathVariable("id") Long configId){
        return ResponseResult.isSuccess(dictConfigService.openInvalidConfig(configId));
    }

    @GetMapping("/invalidConfig/{id}")
    @ApiOperation("作废配置")
    public ResponseResult<Boolean> invalidConfig(@PathVariable("id") Long configId){
        return ResponseResult.isSuccess(dictConfigService.invalidConfig(configId));
    }

}
